<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f = "http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" 
      xmlns:ui="http://java.sun.com/jsf/facelets">
        <h:head>
                <title>Facelet Title</title>
        </h:head>
        <h:body>
                <ui:composition template="./BannersAndMenusTemplate.jsf"> 

            <ui:define name="content" rendered="#{user.login}">
                <p:panel header="Formats">  

                    <h:form id="wrapperForm" rendered="#{user.login}"> 

                        <p:dataTable id="dataTableForViewSets" var="Format" value="#{user.allFormats()}" widgetVar="Format"   
                                     emptyMessage="No Formats found with given criteria" 
                                     selection="#{user.selectedFormat}" selectionMode="single"  rowKey="#{Format.id}"  
                                     paginator="#{user.checkIfTenOrMore('format')}" rows="10" rowsPerPageTemplate="10" lazy="false"  
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" >    
 
                            <p:ajax event="rowSelect" listener="#{user.onRowSelectFOR}"    
                                    update=":wrapperForm:dataTableForViewSets" />  
                            <p:ajax event="rowUnselect" listener="#{user.onRowUnselectFOR}" update=":wrapperForm:dataTableForViewSets"/>  

                            <f:facet name="footer">     

                                <p:commandButton  id="showDialogButton" type="button" value="Add" icon="ui-icon-pencil"  
                                                  onclick="dlg1.show();" /> 


                                <p:dialog id="basicDialog" header="Enter Format" widgetVar="dlg1" resizable="false">  
                                    <!--  <h:form id="form"> -->

                                    <!--<h:panelGrid columns="2" style="margin-bottom:10px; border: none;" > -->     
                                    <h:outputLabel for="firstnameeeeee" value="Name:" />  
                                    <p:inputText id="firstnameeeeee" value="#{user.currentFormat.name}" />  
                                    <!-- </h:panelGrid>   --> 

                                    <p:commandButton id="submitButtonqwe" value="Submit" actionListener="#{user.addFormat}" ajax="false" oncomplete="dlg1.hide();"/>  

                                    <!--  </h:form> -->    
                                </p:dialog>

  

                                <p:commandButton  id="showDialogButton2" value="Rename" rendered="#{user.renderOnRowSelectFOR}" 
                                                  type="button" icon="ui-icon-pencil"  onclick="dlg2.show();" ajax="true" 
                                                  update=":wrapperForm:display"
                                                  > 
                                    <f:setPropertyActionListener value="#{Format.name}" target="#{user.selectedFormatNameForRename}" />   
                                </p:commandButton>    

                                <p:dialog id="basicDialogsdf" header="Enter New Academic Set Name" widgetVar="dlg2" resizable="false">    
                                    <!--   <h:form id="form2">   -->  

                                    <!--<h:panelGrid columns="2" style="margin-bottom:10px">  --> 
                                    <h:outputLabel for="firstname" value="New Name:" />  
                                    <p:inputText id="firstname" value="#{user.selectedFormatNameForRename}" />  
                                    <!-- </h:panelGrid> --> 

                                    <p:commandButton id="submitButtonrty" value="Rename" actionListener="#{user.selectedFormatRename}" ajax="false" oncomplete="dlg2.hide();"/>  

                                    <!--   </h:form>  -->
                                </p:dialog> 


                                <p:growl id="messages" showDetail="true" sticky="false"/> 
    

                                <p:commandButton  id="showDialogButtonDelete" value="Delete"  onclick="confirmation.show();" icon="ui-icon-close" rendered="#{user.renderOnRowSelectFOR}"
                                                  /> 





                                <p:confirmDialog id="confirmDialog" message="Are you sure about delete the Format?"  
                                                 header="Delete Format!" severity="alert" widgetVar="confirmation">  

                                    <p:commandButton id="confirm" value="Yes" update=":wrapperForm" oncomplete="confirmation.hide()"  
                                                     actionListener = "#{user.selectedFormatDelete}" ajax="true"/>   
                                    <p:commandButton id="decline" value="No" onclick="confirmation.hide();" type="button" />   

                                </p:confirmDialog>  



                                <p:commandButton  id="showDialogButtonEdit" value="Customize" icon="ui-icon-newwin" rendered="#{user.renderOnRowSelectFOR}"
                                                  action = "#{user.gotodetailsFor()}"/> 

                            </f:facet>     

                            <p:column filterBy="#{Format.name}"   
                                      headerText="Name"  
                                      filterMatchMode="contains" >  
                                <h:outputText value="#{Format.name}" />   </p:column> 






                        </p:dataTable> 

                    </h:form> 


                </p:panel> 

            </ui:define>

        </ui:composition>
        </h:body>
</html>

